package com.example.demo.service;


import com.example.demo.mapper.GoodsMapper;
import com.example.demo.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yanglup
 * @create 2020-11-19 19:28
 */
@Service
public class GoodsServiceImpl implements GoodsService{
    @Autowired
    private GoodsMapper goodsMapper;


    /**添加图书*/
    @Override
    public void GoodsaddServiceInsert(Goodsadd goodsadd) {
        String goods_serial=System.currentTimeMillis()+"123";
        goodsMapper.Goodsaddmapperinsert(goodsadd.getCat_id(),goodsadd.getGoods_name(),goodsadd.getGoods_price(),
                goodsadd.getGoods_number(),goodsadd.getSchool(),goodsadd.getGoods_oldnew(),
                goodsadd.getGoods_described(),goodsadd.getGoods_small_logo(),goodsadd.getGoods_small_logo2(),goodsadd.getGoods_small_logo3(),
                goodsadd.getCat_one_id(), goodsadd.getCat_two_id(),goods_serial,goodsadd.getOpenid(),goodsadd.getStatus());
    }





    /**图书分类*/
    @Override
    public List<Goodsfenlei1> Goodsqueryfenlei1() {
        return goodsMapper.Goodsqueryselect1();
    }
    @Override
    public List<Goodsfenlei2> Goodsqueryfenlei2(Integer number1, Integer number2) {
        return goodsMapper.Goodsqueryselect2(number1, number2);
    }





    /**商品列表--分类里跳转*/
    @Override
    public List<Goodlist> Goodsquerylistservice(Integer cat_one_id, Integer cat_two_id, Integer pagenum, Integer pagesize) {
        return goodsMapper.Goodsquerylist(cat_one_id,cat_two_id,pagenum,pagesize);
    }
    /**商品列表查某分类里数量*/
    @Override
    public Integer Goodsquerylistcount(Integer cat_one_id, Integer cat_two_id) {
        return goodsMapper.Goodsquerylistcount(cat_one_id,cat_two_id);
    }






    /**商品详情1*/
    @Override
    public Goodsdetail1 Goodsquerydetail(Integer goods_id) {
        return goodsMapper.Goodsquerydetail1(goods_id);
    }
    /**插入图片3张*/
    @Override
    public void Goodsdetail2insert(Integer goods_id) {
        List<Goodsdetail2> list=goodsMapper.Goodsquerydetail2(goods_id);
        if(null == list || list.size() ==0){
            goodsMapper.Goodsdetail2insert1(goods_id);
            goodsMapper.Goodsdetail2insert2(goods_id);
            goodsMapper.Goodsdetail2insert3(goods_id);
        }

    }
    /**商品详情2*/
    @Override
    public List<Goodsdetail2> Goodsquerydetail2(Integer goods_id) {
        return goodsMapper.Goodsquerydetail2(goods_id);
    }



    /**搜索商品*/
    @Override
    public List<Goodsquerybookname> Goodsquerybookname(String query) {
        return goodsMapper.Goodsquerybookname(query);
    }




    /**反馈信息*/
    @Override
    public void Feedback(Feedback feedback) {
        goodsMapper.Feedbackinsert(feedback.getMinproblem(),feedback.getUrl(),feedback.getTextVal());
    }





    /**删除商品*/
    @Override
    public void deletegoods(String openid, Integer goods_id) {
        goodsMapper.deletegoods(openid,goods_id);
    }


}
